<?php

// phpMyRealty 3
//
// File Name: navigation.php
// File Location : ./admin/
//
// Copyright (c)2009 phpMyRealty.com
//
// e-mail: support@phpMyRealty.com

// NAVIGATION WINDOW
if (!defined('PMRADMIN') || (defined('PMRADMIN') && PMRADMIN != 'true')) die();

// Warn them if the license is going to expire soon
if (licenseExpiration() <= 30)
	echo htmlErrorBox('<b>Warning: Your License will expire in <a href="http://www.phpmyrealty.com/purchase.html" target="_blank">' . licenseExpiration() . ' day(s)</a>. Why wait? <a href="http://www.phpmyrealty.com/purchase.html" target="_blank">Order</a> a license to phpMyRealty today!</b>');

// Warn them if their administrator password should be changed
if ($session->fetch('adminlogin') == 'admin' && $session->fetch('adminpassword') == md5('admin'))
 echo htmlErrorBox('<b>Warning: Your default Administrator details should be <a href="' . URL . '/admin/editadmins.php">UPDATED</a> to secure your system.</b>');

echo table_header ( $lang['Module_Admin'] );

echo ' <table cellpadding="5" cellspacing="0" border="0"> <tr>';

// Make sure this admin have access to this script
if (adminPermissionsCheck('manage_users', $session->fetch('adminlogin')))
 echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/index.php?menuid=1"><img src="' . URL . '/admin/template/images/icons/users.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Top_Menu_Manage_Users'] . '</a></td>';

if (adminPermissionsCheck('manage_listings', $session->fetch('adminlogin')))
 echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/index.php?menuid=2"><img src="' . URL . '/admin/template/images/icons/listings.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Top_Menu_Manage_Listings'] . '</a></td>';

if (adminPermissionsCheck('manage_types', $session->fetch('adminlogin')))
 echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/index.php?menuid=4"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Top_Menu_Manage_Types_Locations'] . '</a></td>';

if (adminPermissionsCheck('manage_settings', $session->fetch('adminlogin')))
 echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/index.php?menuid=5"><img src="' . URL . '/admin/template/images/icons/config.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Top_Menu_Configuration_Settings'] . '</a></td>';

if (adminPermissionsCheck('manage_administrators', $session->fetch('adminlogin')))
 echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/index.php?menuid=6"><img src="' . URL . '/admin/template/images/icons/admins.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Top_Menu_Manage_Administrators'] . '</a></td>';

 echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/cms.php"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br />CMS</a></td>';

 echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/mailer.php"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Mailer'] . '</a></td>';

 echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/index.php?menuid=7"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br />Export / Import</a></td>';

 echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/alerts.php"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br />' . $lang['Alert'] . '</a></td>';
 echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/alertsMailer.php"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br />Alerts Mailer</a></td>';

 echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/index.php"><img src="' . URL . '/admin/template/images/icons/statistics.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Statistics'] . '</a></td>';

 echo '<td width="80" align="center" valign="top"><a href="' . URL . '/index.php?req=logout"><img src="' . URL . '/admin/template/images/icons/logout.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Top_Menu_Logout'] . '</a></td>';

echo ' </tr></table> ';

echo table_footer();

// Put menu ID into the session variable
if (isset($_GET['menuid']) && eregi('^[0-9]+$', $_GET['menuid']))
 $session->set('navigation', $_GET['menuid']);

// Manage Users.
if ((isset($_GET['menuid']) && $_GET['menuid'] == '1' && eregi('^[0-9]+$', $_GET['menuid'])
OR ($session->fetch('navigation') == '1')) && adminPermissionsCheck('manage_users', $session->fetch('adminlogin')))

 {

  echo table_header ( $lang['Admin_Top_Menu_Manage_Users'] );

  echo ' <table cellpadding="5" cellspacing="0" border="0"> <tr>';

  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/findusers.php?realtor_approved=YES"><img src="' . URL . '/admin/template/images/icons/approve.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Approve_New_Users'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/findusers.php?realtor_updated=YES&realtor_updated_days=5"><img src="' . URL . '/admin/template/images/icons/approve.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Approve_Updated_Users'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/addusers.php"><img src="' . URL . '/admin/template/images/icons/addusers.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Add_Users'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/findusers.php"><img src="' . URL . '/admin/template/images/icons/users.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Edit_Users'] . '</a></td>';

  echo ' </tr></table> ';

  echo table_footer();

 }

// Manage Listings.
if ((isset($_GET['menuid']) && $_GET['menuid'] == '2' && eregi('^[0-9]+$', $_GET['menuid'])
OR ($session->fetch('navigation') == '2')) &&  adminPermissionsCheck('manage_listings', $session->fetch('adminlogin')))

 {

  echo table_header ( $lang['Admin_Top_Menu_Manage_Listings'] );

  echo ' <table cellpadding="5" cellspacing="0" border="0"> <tr>';

  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/findlistings.php?listing_approved=YES"><img src="' . URL . '/admin/template/images/icons/approve.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Approve_New_Listings'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/findlistings.php?listing_expired=YES"><img src="' . URL . '/admin/template/images/icons/approve.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Expired_Listings'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/findlistings.php?listing_updated=YES&listing_updated_days=5"><img src="' . URL . '/admin/template/images/icons/approve.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Approve_Updated_Listings'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/findlistings.php"><img src="' . URL . '/admin/template/images/icons/listings.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Edit_Listings'] . '</a></td>';

  echo ' </tr></table> ';

  echo table_footer();

 }

// Manage Types, Locations etc.
if ((isset($_GET['menuid']) && $_GET['menuid'] == '4' && eregi('^[0-9]+$', $_GET['menuid'])
OR ($session->fetch('navigation') == '4')) && adminPermissionsCheck('manage_types', $session->fetch('adminlogin')))

 {

  echo table_header ( $lang['Admin_Top_Menu_Manage_Types_Locations'] );

  echo ' <table cellpadding="5" cellspacing="0" border="0"> <tr>';

  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/edit_custom.php?req=custom"><img src="' . URL . '/admin/template/images/icons/edittypes.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Custom_Types'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/edit.php?req=types"><img src="' . URL . '/admin/template/images/icons/edittypes.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Property_Types'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/edit.php?req=types2"><img src="' . URL . '/admin/template/images/icons/edittypes.png" valign="top" border="0" alt=""><br />' . $lang['Module_Listing_Type'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/edit.php?req=styles"><img src="' . URL . '/admin/template/images/icons/edittypes.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Styles'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/edit.php?req=locations"><img src="' . URL . '/admin/template/images/icons/editlocations.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Locations'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/editlocations.php"><img src="' . URL . '/admin/template/images/icons/editlocations.png" valign="top" border="0" alt=""><br />' . $lang['admin_3level'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/edit.php?req=buildings"><img src="' . URL . '/admin/template/images/icons/editetc.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Additional_Out_Buildings'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/edit.php?req=appliances"><img src="' . URL . '/admin/template/images/icons/editetc.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Appliances_Included'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/edit.php?req=features"><img src="' . URL . '/admin/template/images/icons/editetc.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Features'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/edit.php?req=basement"><img src="' . URL . '/admin/template/images/icons/editetc.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Basement'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/edit.php?req=garage"><img src="' . URL . '/admin/template/images/icons/editetc.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Garage'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/edit.php?req=status"><img src="' . URL . '/admin/template/images/icons/editetc.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Status'] . '</a></td>';

  echo ' </tr></table> ';

  echo table_footer();

 }

// Manage Settings
if ((isset($_GET['menuid']) && $_GET['menuid'] == '5' && eregi('^[0-9]+$', $_GET['menuid'])
OR ($session->fetch('navigation') == '5')) && adminPermissionsCheck('manage_settings', $session->fetch('adminlogin')))

 {

  echo table_header ( $lang['Admin_Top_Menu_Configuration_Settings'] );

  echo ' <table cellpadding="5" cellspacing="0" border="0"> <tr>';

  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/config.php"><img src="' . URL . '/admin/template/images/icons/config.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Configuration_Settings'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/packages.php"><img src="' . URL . '/admin/template/images/icons/config.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Packages'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/agentpackages.php"><img src="' . URL . '/admin/template/images/icons/config.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Agent_Packages'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/dbbackup.php"><img src="' . URL . '/admin/template/images/icons/databasebackup.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Database_Backup'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/banemails.php"><img src="' . URL . '/admin/template/images/icons/ban.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Ban_e_mails'] . '</a></td>';

  echo ' </tr></table> ';

  echo table_footer();

 }

// Manage Administrators
if ((isset($_GET['menuid']) && $_GET['menuid'] == '6' && eregi('^[0-9]+$', $_GET['menuid'])
OR ($session->fetch('navigation') == '6')) && adminPermissionsCheck('manage_administrators', $session->fetch('adminlogin')))

 {

  echo table_header ( $lang['Admin_Top_Menu_Manage_Administrators'] );

  echo ' <table cellpadding="5" cellspacing="0" border="0"> <tr>';

  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/editadmins.php"><img src="' . URL . '/admin/template/images/icons/addusers.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Edit_Administrators'] . '</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/privileges.php"><img src="' . URL . '/admin/template/images/icons/editpriveleges.png" valign="top" border="0" alt=""><br />' . $lang['Admin_Edit_Privileges'] . '</a></td>';

  echo ' </tr></table> ';

  echo table_footer();

 }

// Import / Export
if ((isset($_GET['menuid']) && $_GET['menuid'] == '7' && eregi('^[0-9]+$', $_GET['menuid'])))

 {

  echo table_header ( 'Import / Export' );

  echo ' <table cellpadding="5" cellspacing="0" border="0"> <tr>';

  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/import.php"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br />CSV Import (beta)</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/export.php"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br />CSV Export (beta)</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/locimport.php"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br />3-level Locations Import (beta)</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/zipimport.php"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br />ZIP Codes Radius Search Import (beta)</a></td>';
  echo '<td width="80" align="center" valign="top"><a href="' . URL . '/admin/idx.php"><img src="' . URL . '/admin/template/images/icons/manage.png" valign="top" border="0" alt=""><br />IDX Import (beta)</a></td>';

  echo ' </tr></table> ';

  echo table_footer();

 }

?>